package com.example.employee.domain.dto;

import com.example.employee.validation.CustomValidation;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Range;

import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "广告数据模型")
public class AdvertiseDTO {
    /** 广告ID（自增主键） */
    @Schema(description = "广告id",example = "1")
    private Long id;

    /** 广告名称 */
    @Schema(description = "广告名称",example = "普洱茶")
    @NotBlank
    private String name;

    /** 广告图片URL */
    @Schema(description = "广告图片URL",example = "")
    @NotBlank
    private String imageUrl;

    /** 点击跳转URL */
    @Schema(description = "点击跳转URL",example = "6")
    @NotBlank
    private String linkUrl;

    /** 展示位置（1:小程序首页 2:分类页 3:网页首页） */
    @Schema(description = "展示位置",example = "1")
    @NotNull
    @Range(min = 1, max = 3, message = "非法广告位置")
    private Integer position;

    /** 广告开始生效时间 */
    @Schema(description = "广告开始生效时间",example = "2025-07-27T00:00:00")
    @FutureOrPresent(message = "开始时间不能早于当前时间")
    private LocalDateTime startTime;

    /** 广告结束时间 */
    @Schema(description = "广告结束时间",example = "2025-07-31T00:00:00")
    @Future(message = "结束时间必须晚于当前时间")
    @CustomValidation(type = "business", rule = "endAfterStart")
    private LocalDateTime endTime;

    /** 状态（1:正常 2:下架 3:删除） */
    @Schema(description = "状态",example = "1")
    @NotNull
    @Range(min = 1, max = 3, message = "非法状态值")
    private Integer status;

    /** 排序权重（越大越靠前） */
    @Schema(description = "排序权重",example = "0")
    @Min(value = 0, message = "排序值不能为负")
    @Max(value = 9999, message = "排序值超过最大值")
    private Integer sortOrder;

}

